package send;

import com.alibaba.fastjson.JSONObject;
import com.joymeter.common.utils.Compare;
import com.joymeter.common.utils.DruidQueryUtil;
import com.joymeter.common.utils.HttpClient;
import com.joymeter.common.utils.TimeTools;
import org.junit.Test;
import org.springframework.util.StringUtils;

import java.text.ParseException;
import java.util.Date;

/**
 * @ClassName test
 * @Description TODO
 * @Author liang
 * @Date 2018/8/22 14:42
 * @Version 1.0
 **/
public class test {

    @Test
    public void test1() throws Exception {
        String json = "{\"serverId\":\"0\",\"deviceId\":\"000000000000\",\"type\":\"2200\",\"event\":\"data_failed\",\"data\":\"data\",\"datetime\":\"1535094297000\",\"msg\":\"eyJlcnJjb2RlIjoiMCIsImVycm1zZyI6Ik9LIiwibXNnVHlwZSI6ImV2ZW50IiwiZXZlbnQiOiJwdXNoIiwiZGV2aWNlIjp7ImlkIjoiMzE4MDcwMDAwNTM1IiwiYXBwRXVpIjoiMDEwMDAxMDEwMDU5NEY0QSIsImRhdGEiOiIxMzA0LjE2Iiwic3RhdGUiOiIxIiwiZGF0ZXRpbWUiOiIyMDE4MDgxMzAwMTMxOSJ9fQ\"}";
        String url2 = "http://127.0.0.1:18080/deviceInfo/addEventData";
        String url = "http://192.168.10.168:18080/deviceInfo/addEventData";
        for(int i =0;i<1000;i++){
            String s = HttpClient.sendPost(url2, json);
            System.out.println(s);

        }
    }

    @Test
    public void test2(){
        String url = "http://api.map.baidu.com/geocoder/v2/";
        String param = "address=杭州&ak=I16RYfqvkctrSkyHcjAghhOnNXQSHFhv";
        int count =0;
        for(int i=0;i<4000;i++){
            String s = HttpClient.sendGet(url, param);
            if(s == null){
                count ++;
            }

        }
        System.out.println("失败："+count+"次");
    }

    @Test
    public void test3(){
        String url = "http://api.map.baidu.com/geocoder/v2/";
        String param = "address=杭州&ak=I16RYfqvkctrSkyHcjAghhOnNXQSHFhv";
        int count =0;
        for(int i=0;i<4000;i++){
            String s = HttpClient.sendGet(url, param);
            if(s.length() != 14879){
                count ++;
            }

        }
        System.out.println("失败："+count+"次");
    }

}
